using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OrnamentalBlade:MeleeWeapon {

	public OrnamentalBlade(WeaponData weaponData) : base(weaponData) {
		projectileCircle=ProjectileData.nameToData["MeleeCircle"];
		projectilePierce=ProjectileData.nameToData["MeleePierce"];
	}

	int attackIndex;
	const int attackCount = 3;

	ProjectileData projectileCircle;
	ProjectileData projectilePierce;

	protected override void PreProcess(ShotStats shot) {
		if(slot.inAfterAttack||slot.inAttack)
			attackIndex=(attackIndex+1)%attackCount;
		base.PreProcess(shot);
	}
	protected override void PreProcessNormal(ShotStats shot) {
		base.PreProcessNormal(shot);
		if(attackIndex==1) shot.projectile=projectileCircle;
		if(attackIndex==2) shot.projectile=projectilePierce;
	}

	protected override void ProjectileFiringEventHandler(object _sender,ProjectileEventArgs e) {
		base.ProjectileFiringEventHandler(_sender,e);
		if(!IfReactFireEvent(_sender,e)) return;
		if(attackIndex==2) {
			e.stat.damage.AddMultiply(1.3f,-100);
			e.stat.damagePrototype.crit=true;
		}
		if(_sender is ProjectileMeleeCircle) {
			ProjectileMeleeCircle sender = _sender as ProjectileMeleeCircle;
			sender.isCCW=true;
		}
	}

	public override void Update() {
		base.Update();
		if(!slot.inAfterAttack&&!slot.inAttack)
			attackIndex=0;

		slot.SetAttackIndex(attackIndex);
	}
}
